﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EPanShareSystem.Commom;
using EPanShareSystem.Model;

namespace EPanShareSystem.Web.Controllers
{
    public class MyWebFileController : Controller
    {
        //
        // GET: /MyWebFile/

        public ActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 创建目录
        /// </summary>
        /// <returns></returns>
        public JsonResult CreateDir(string dirName)
        {
            string msg = string.Empty;
            bool flag = false;
            string dir = "~/Data/" + LoginContenxt.CurrentUserInfo().userName + "/" + dirName;
            string obsoluteDir = Server.MapPath(dir);
            try
            {

                if (string.IsNullOrEmpty(dirName))
                {
                    msg = "参数错误";
                }
                else
                {
                    if (DirFileHelper.IsExistDirectory(obsoluteDir))
                    {
                        msg = "当前目录已存在，请更换目录名称";
                    }
                    else
                    {
                        DirFileHelper.CreateDirectory(obsoluteDir);
                        msg = "创建成功";
                        flag = true;
                    }
                    
                }
                
              
            }
            catch (Exception)
            {
                msg = "创建失败";
            }        
            return Json(new { flag = flag, msg = msg }, JsonRequestBehavior.AllowGet);
        }  
    }
}
